/*
* Copyright (c) 2006 by Kirill Kolodyazhniy.
* See the file "license.terms" for information on usage and redistribution.
*/

#ifndef M_INPUTSYSTEM_H
#define M_INPUTSYSTEM_H

#include "signal.h"
#include "factory.h"
#include "common.h"
#include "renderwindowinfo.h"

namespace Engine
{
	/**
	*   Abstract class defining base of input systems.
	*/
	class InputSystem
	{
	public:
		enum MouseButton
		{
		   LeftButton,
		   RightButton,
		   MiddleButton
		};

		virtual ~InputSystem(){};

		/**
		*   Initialize system.
		*   @param param system specific parameter.
		*/
		virtual void Init(RefPtr<RenderWindowInfo> param, bool exclusive = true) = 0;

		/**
		*   Close all devices.
		*/
		virtual void Close() = 0;

		/**
		*   Return true in system is in exclusive mode.
		*/
		virtual bool IsExclusive() = 0;

		/**
		*   Toggle exclusive mode.
		*/
		virtual void ToggleExclusive(bool val) = 0;

		/**
		*   Relative mouse movements.
		*/
		Signal<REAL,REAL> MouseMoveSignal;

		/**
		*   A mouse button has been pressed down.
		*/
		Signal<MouseButton> MouseButtonDownSignal;

		/**
		*   A mouse button has been released.
		*/
		Signal<MouseButton> MouseButtonUpSignal;

		/**
		*   A key has been pressed.
		*/
		Signal<unsigned int> KeyDownSignal;

		/**
		*   A key has been released.
		*/
		Signal<unsigned int> KeyUpSignal;

		/**
		*   A char has been pressed.
		*/
		Signal<unsigned short> CharPressedSignal;

		/**
		*   Use of the mouse wheel or scroll wheel.
		*/
		Signal<REAL> MouseWheelChangeSignal;

		/**
		*   Absolute position of the mouse.
		*/
		virtual void GetMousePosition( REAL* x_pos, REAL* y_pos ) const = 0;

		/**
		*   Update device state.
		*/
		virtual void Update() = 0;

		/**
		*   Set mouse  moving area dimensions.
		*/
		virtual void SetMouseArea(unsigned int width, unsigned int height) = 0;
	};

	/**
	*   Factory for creating input systems.
	*/
	class InputSystemFactory: public Factory<InputSystem>
	{
	};
}

#endif
